<!DOCTYPE html>
<html>
<head>
    <title>File List</title>
    <style>
        .grid-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
            gap: 20px;
        }
        .grid-item {
            flex: 0 1 calc(31% - 20px); /* 计算每行三个图片的宽度 */
            text-align: center;
            margin-bottom: 20px;
        }
        .grid-item img {
            max-width: 100%;
            max-height: 100%;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        /* 媒体查询，调整在较大屏幕上的布局 */
        @media (max-width: 992px) {
            .grid-item {
                flex: 0 1 calc(50% - 20px); /* 在较小屏幕上显示两列 */
            }
        }
    </style>
</head>
<body>
    <h2>File List</h2>
    <div class="grid-container">
        {% for file in files %}
        {% if file.endswith('.jpg') or file.endswith('.png') or file.endswith('.jpeg') %}
        <div class="grid-item">
            <a href="{{ url_for('download_file', filename=file) }}">{{ file }}</a><br>
            <img src="{{ url_for('download_file', filename=file) }}" alt="{{ file }}">
        </div>
        {% endif %}
        {% endfor %}
    </div>
</body>
</html>
